/**
 * @(#)EnumerationAgregable.java Jan 31, 2007
 *
 * Copyright (c) 2005-2010 Psiqueware S.A. de C.V. All Rights Reserved.
 * This software is the proprietary information Psiqueware S.A. de C.V.
 * Use is subject to license terms.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 *
 * <br/>Usuario : AngelElectrico
 * <br/>Creaci&oacute;n: Jan 31, 2007 - 11:26:37 AM
 * <br/>
 * <br/>
 * <br/><t5>Cambios :</t5>
 * <br/><b>Fecha | Autor  |  Cambios</b>
 * <ul>
 * <li>Jan 31, 2007 | <a href = "mailto:AngelElectrico@PsiqueWare.com">Angel El&eacute;ctrico</a> | Creaci&oacute;n del Objeto.</li>
 *
 * </ul>
 */

package com.psiqueware.alheli.i18n.propertyBundles;

import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;

/**
 * Enumeraci&oacute;n de las llaves de un contexto de bundles.
 * <br/>Paquete Original: com.psiqueware.basico.i18n
 * <br/>Nombre  Original: EnumerationAgregable
 * <br/>Oprima para ver : <a href="EnumerationAgregable.java.html"><i>C&oacute;digo Fuente</i> </a>
 *
 * @author <a href="mailto:AngelElectrico@PsiqueWare.com">Angel El&eacute;ctrico</a>
 * @version Revision: 1.1 Jan 31, 2007 11:26:37 AM
 * @noinspection ClassWithoutLogger
 */
public final class EnumerationAgregable implements Enumeration<String>
{

    /**
     * Lista de las llaves contenidas en esta enumeraci&oacute;n.
     *
     * @noinspection MagicNumber
     */
    private final List<String> m_keys = new ArrayList<String>(150);

    /**
     * Indice actual en la lista.
     */
    private int m_indice;

    /**
     * Constructor de EnumerationAgregable.
     */
    public EnumerationAgregable()
    {

    }

    /**
     * Agrega una llave a la enumeraci&oacute;n.
     *
     * @param key a agregar.
     *
     * @noinspection NonBooleanMethodNameMayNotStartWithQuestion
     */
    public void addKey(String key)
    {
        m_keys.add(key);
    }

    /**
     * Tests if this enumeration contains more elements.
     *
     * @return <code>true</code> if and only if this enumeration object
     *         contains at least one more element to provide;
     *         <code>false</code> otherwise.
     */
    public boolean hasMoreElements()
    {
        return m_indice < m_keys.size();
    }

    /**
     * Returns the next element of this enumeration if this enumeration
     * object has at least one more element to provide.
     *
     * @return the next element of this enumeration.
     *
     * @throws java.util.NoSuchElementException
     *          if no more elements exist.
     * @noinspection ValueOfIncrementOrDecrementUsed
     */
    public String nextElement()
    {
        return m_keys.get(m_indice++);
    }

    /**
     * Convierte este {@link EnumerationAgregable} a su representaci&oacute;n textual.
     *
     * @noinspection DuplicateStringLiteralInspection, HardCodedStringLiteral, HardcodedLineSeparator
     */
    public String toString()
    {
        StringBuilder sb = new StringBuilder();
        sb.append("<Instance Class = '").append(this.getClass().getCanonicalName()).append("'>");
        sb.append("<indice>").append(m_indice).append("</indice> ");
        sb.append("<keys>").append(m_keys).append("</keys> ");
        sb.append("</Instance>");
        return sb.toString();
    }
}

